import datetime

import execjs
import requests

def get_des_psswd(pwd):
    jsstr = get_js()
    ctx = execjs.compile(jsstr) #加载JS文件
    return (ctx.call('rsaPwd', "10001","967094d470dc7940f32ab7e8b701cf2ca732c7cd7aed176ecd8cac605da26e5fc8664382bb2c0b73b8a0109016130ff0c0f73985fa990a18466008b14284969d58f2c2c2698f91b6dcc6bebd90663d288dca79586b8294a56619dd87ab21274088c318e26b6e3210b165118b87ebc8798df572b2b84cfa9fe54d04e3b8dc1b25",pwd))  #调用js方法  第一个参数是JS的方法名，后面的data和key是js方法的参数



def get_js():
    f = open("pwd.txt", 'r', encoding='utf-8') # 打开JS文件
    line = f.readline()
    htmlstr = ''
    while line:
        htmlstr = htmlstr+line
        line = f.readline()
    f.close()
    return htmlstr


class Mail_163():

    def login(self,user,pwd):
        data = {
            'method': 'login',
            'back_url': '',
            'timestamp': '0',
            'm': '1',
            'register': '0',
            'wml': 'false',
            'srandid': '',
            'ucid': '',
            'publicExponen': '10001',
            'modulus': '967094d470dc7940f32ab7e8b701cf2ca732c7cd7aed176ecd8cac605da26e5fc8664382bb2c0b73b8a0109016130ff0c0f73985fa990a18466008b14284969d58f2c2c2698f91b6dcc6bebd90663d288dca79586b8294a56619dd87ab21274088c318e26b6e3210b165118b87ebc8798df572b2b84cfa9fe54d04e3b8dc1b25',
            'username': user,
            'domain': '163.com',
            'password': get_des_psswd(pwd)
        }
        s = requests.session()
        s.post('http://m77.mm.mail.163.com/login.s', data=data)
        if s.cookies['NTES_SESS']!=None:
            return s.cookies



if __name__ == '__main__':
   print('2018/07/19 17:43:27'  > '2018/07/18 17:43:36')
